package com.hyz.controller;

import com.hyz.pojo.ResponseResult;
import com.hyz.pojo.assetManager.GetAssetImportsByAssetManagerIdResponse;
import com.hyz.pojo.assetManager.InsertAssetImportRequest;
import com.hyz.pojo.assetManager.UnassignedAssetResponse;
import com.hyz.pojo.assetSecondment.AssetSecondmentResponse;
import com.hyz.service.AssetManagerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pojo.asset.Repository;

import java.util.List;


/**
 * @author HGD
 * @date 2022/10/3 17:48
 */
@Api("资产管理员")
@RestController
@RequestMapping("/assetManager")
public class AssetManagerController {
    @Autowired
    private AssetManagerService service;

    // 资产管理----------------------------------------------------------------

    @ApiOperation("资产管理员获取未分库资产")
    @ApiResponse(code = 200, message = "成功", response = ResponseResult.class)
    @PostMapping("/getUnassignedAsset")
    public ResponseResult<List<UnassignedAssetResponse>> getUnassignedAsset() {
        return service.getUnassignedAsset();
    }

    @ApiOperation(("搜索所有仓库列表"))
    @ApiResponse(code = 200, message = "成功", response = ResponseResult.class)
    @PostMapping("/getAllRepositories")
    public ResponseResult<List<Repository>> getAllRepositories() {
        return service.getAllRepositories();
    }

    @ApiOperation(("资产入库"))
    @ApiParam("入库请求")
    @ApiResponse(code = 200, message = "成功", response = ResponseResult.class)
    @PostMapping("/batchInsertAssetImports")
    public ResponseResult<String> batchInsertAssetImports(@RequestBody InsertAssetImportRequest request) {
        return service.batchInsertAssetImports(request);
    }

    @ApiOperation(("通过资产管理员id获取资产入库状况"))
    @ApiResponse(code = 200, message = "成功", response = ResponseResult.class)
    @PostMapping("/getAssetImportsByAssetManagerId")
    public ResponseResult<List<GetAssetImportsByAssetManagerIdResponse>> getAssetImportsByAssetManagerId() {
        return service.getAssetImportsByAssetManagerId();
    }

    // 资产借用----------------------------------------------------------------

    @ApiOperation(("获取资产借用申请"))
    @ApiResponse(code = 200, message = "成功", response = ResponseResult.class)
    @PostMapping("/amGetAssetSecondments")
    public ResponseResult<List<AssetSecondmentResponse>> amGetAssetSecondments() {
        return service.amGetAssetSecondments();
    }
}
